<?php

namespace app\api\validate;

use app\common\model\ShortUrlLog;
use think\exception\ValidateException;

class BuildValidate extends \app\common\validate\BasicValidate
{
	protected $rule = [
		'url' => 'require|url',
		'scene' => 'require',
		'appid' => 'require'
	];

	protected $message = [
		'url.require' => '缺少参数url',
		'url.url' => '参数url不合法',
		'appid.require' => '缺少参数appid'
	];

	public function checkScene($value,$rule,$data){
		$scene = array_keys(ShortUrlLog::$sceneMap);
		if(in_array($value,$scene)){
			return true;
		}

		throw new ValidateException('不存在的连接类型');
	}
}
